]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Use gdk_screen_get_primary_monitor on gtk-2.20.1+
authorAdel Gadllah <adel.gadllah@gmail.com>
Wed, 12 May 2010 07:35:32 +0000 (09:35 +0200)
committerAdel Gadllah <adel.gadllah@gmail.com>
Wed, 12 May 2010 07:35:32 +0000 (09:35 +0200)
Starting with gtk-2.20.0 there is a gdk_screen_get_primary_monitor,
which supports querying the primary monitor from xrandr.

But due to a sorting bug and lack of heuristics in the fallback path,
it isn't really useable.

Those bugs are fixed in gtk-2.20.1, so use it when building with
gtk-2.20.1+.

https://bugzilla.gnome.org/show_bug.cgi?id=608647

src/shell-global.c

index 2228ef40ef56e26c3e594d9f4df4a2a950ec35d8..59db2032e6232e2151e33ac6f59dfd99b61b10b9 100644 (file)
@@ -1117,7 +1117,14 @@ shell_global_get_primary_monitor (ShellGlobal  *global)
 {
   GdkScreen *screen = gdk_screen_get_default ();
   GdkRectangle rect;
-  gint i, primary = 0;
+  gint primary = 0;
+
+  /* gdk_screen_get_primary_monitor is only present in gtk-2.20+
+   * and is in a useable state (supports heuristics and fallback modes)
+   * starting with 2.20.1
+   */
+#if !GTK_CHECK_VERSION (2, 20, 1)
+  gint i;
   gchar *output_name = NULL;
   gint num_monitors = gdk_screen_get_n_monitors (screen);
 
@@ -1136,6 +1143,9 @@ shell_global_get_primary_monitor (ShellGlobal  *global)
             }
         }
     }
+#else
+  primary = gdk_screen_get_primary_monitor (screen);
+#endif
 
   gdk_screen_get_monitor_geometry (screen, primary, &rect);